Python 3.8.13 (default, Oct 11 2023, 14:15:07) 
[GCC 11.2.0 20210728 (ROSA)] on linux
Type "help", "copyright", "credits" or "license()" for more information.
>>> a = input()
ls = []
k = 0
for i in range(len(a)):
	if a[i] == '(' or a[i] == '[' or a[i] == '{' or a[i] == '<':
		ls.append(a[i])
	else:
		if len(ls) != 0:
			ls_last = ls.pop()
			if not(ls_last == '(' and a[i] == ')' or ls_last == '[' and a[i] == ']' or ls_last == '{' and a[i] == '}' or ls_last == '<' and a[i] == '>'):
				print('False')
				k= k + 1
				break
		else:
			print("False")
			k = k + 1
if len(ls) == 0 and k != 1:
	print('True')
elif len(ls) != 0 and k != 1: 
    print('False')